<?php
$uid= $_POST['Uid'];
$conn=mysql_connect("localhost:3306", "root", "root") or die("ERROR: Cannot open database");
$db = "footprintdb";
mysql_select_db($db) or die("ERROR: Cannot open database");
$sql = "SELECT * FROM usrtable";
$result = mysql_query ( $sql ) or die (  "Error in query execution. ");
$usrname="";
if (mysql_num_rows ( $result ) > 0) 
{
	while ( $row = mysql_fetch_array ( $result ) ) 
	{
		if ($row ['UsrID'] == $uid) 
		{
			$usrname=$row['UsrName'];
		}
	}
}
$sql = "SELECT * FROM scripttable";
$result = mysql_query ( $sql ) or die ( "Error in query execution. ");
$reply=array();
if (mysql_num_rows ( $result ) > 0) 
{
	while ( $row = mysql_fetch_array ( $result ) ) 
	{
		if ($row ['UsrID'] == $uid) 
		{
			array_push($reply, array(
								'scriptname'=>$row ['ScriptName'],
								'scriptid'=>$row ['ScriptID'],
								'owner'=>$usrname,
								'date'=>$row['Date'],
								'description'=>$row['Description'],
								'tags'=>$row['Tag']
								)
						);   
		}
	}
}
echo json_encode($reply);
?>